//
//  PerfectView.m
//  fitnessmanage
//
//  Created by 众拳科技 on 2017/10/17.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "PerfectView.h"

@implementation PerfectView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = CSWhiteColor;
        
        NSMutableDictionary *attrs = [NSMutableDictionary dictionary];// 创建属性字典
        attrs[NSFontAttributeName] = MidBigFont; // 设置font
        attrs[NSForegroundColorAttributeName] = PlaceHoldColor; // 设置颜色
        
        /**
         头像上传
         */
        UIButton *photoBtn = [[UIButton alloc] init];
        photoBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
        photoBtn.imageView.layer.masksToBounds = YES;
        photoBtn.layer.masksToBounds = YES;
        photoBtn.layer.cornerRadius = 40;
        [photoBtn setImage:[UIImage imageNamed:@"img_pictureloading"] forState:UIControlStateNormal];
        [self addSubview:photoBtn];
        self.photoBtn = photoBtn;
        
        /**
         上传头像
         */
        UILabel *uploadLabel = [[UILabel alloc] init];
        uploadLabel.font = MidFont;
        uploadLabel.textColor = PlaceHoldColor;
        uploadLabel.text = @"上传头像";
        [self addSubview:uploadLabel];
        self.uploadLabel = uploadLabel;
        
        /**
         手机TF
         */
        UITextField *nameTF = [[UITextField alloc] init];
        //        phoneTF.backgroundColor = CSRedColor;
        nameTF.clearButtonMode=UITextFieldViewModeWhileEditing;
        nameTF.font = MidBigFont;
        NSAttributedString *phoneAttStr = [[NSAttributedString alloc] initWithString:@"请输入昵称" attributes:attrs]; // 初始化富文本占位字符串
        nameTF.attributedPlaceholder = phoneAttStr;
        nameTF.textColor = CSColorFromRGB(0x212121);
        [self addSubview:nameTF];
        self.nameTF = nameTF;
        
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = LineBackGroundColor;
        [self addSubview:lineView];
        self.lineView = lineView;
        
        /**
         真实姓名输入
         */
        UITextField *realNameTF  = [[UITextField alloc] init];
        //        phoneTF.backgroundColor = CSRedColor;
        realNameTF.clearButtonMode=UITextFieldViewModeWhileEditing;
        realNameTF.font = MidBigFont;
        NSAttributedString *phoneAttStr1 = [[NSAttributedString alloc] initWithString:@"请输入真实姓名(真实姓名无法修改)" attributes:attrs]; // 初始化富文本占位字符串
        realNameTF.attributedPlaceholder = phoneAttStr1;
        realNameTF.textColor = CSColorFromRGB(0x212121);
        [self addSubview:realNameTF];
        self.realNameTF = realNameTF;
        
        
        UIView *lineView1 = [[UIView alloc] init];
        lineView1.backgroundColor = LineBackGroundColor;
        [self addSubview:lineView1];
        self.lineView1 = lineView1;
        
        /**
         师傅教练选择
         */
        CommonBtnView *choseBtn = [[CommonBtnView alloc] init];
        choseBtn.titleLabel.text = @"类型*";
        choseBtn.choseLabel.text = @"选择类型";
        choseBtn.choseLabel.textColor = PlaceHoldColor;
        [self addSubview:choseBtn];
        self.typeBtnView = choseBtn;
        
        /**
         下一步按钮
         */
        UIButton *nextBtn = [[UIButton alloc] init];
        nextBtn.backgroundColor = ButtonBackGroundColor;
        nextBtn.layer.cornerRadius = 4;
        nextBtn.layer.masksToBounds = YES;
        [nextBtn setTitle:@"下一步"];
        [nextBtn setTitleColor:CSBlackColor];
        nextBtn.titleLabel.font = BigFont;
        [self addSubview:nextBtn];
        self.nextBtn = nextBtn;

        
        [self setConstraints];
    }
    
    return self;
}


-(void)setConstraints{
    
    
    
    /**
     头像上传
     */
    [self.photoBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self).offset(30);
        
        make.centerX.mas_equalTo(self);
        
        make.width.height.mas_equalTo(80);
    }];
    
    /**
     上传头像
     */
    [self.uploadLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self.photoBtn);
        
        make.top.mas_equalTo(self.photoBtn.mas_bottom).offset(12);
    }];
    
    
    [self.nameTF mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.uploadLabel.mas_bottom).offset(30);
        
        make.left.mas_equalTo(self).offset(25);
        
        make.right.mas_equalTo(self).offset(-25);
        
        make.height.mas_equalTo(40);
    }];
    
    [self.lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.width.mas_equalTo(self.nameTF);
        
        make.height.mas_equalTo(1);
        
        make.top.mas_equalTo(self.nameTF.mas_bottom).offset(10);
    }];
    
    [self.realNameTF mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.lineView.mas_bottom).offset(20);
        
        make.left.mas_equalTo(self).offset(25);
        
        make.right.mas_equalTo(self).offset(-25);
        
        make.height.mas_equalTo(40);
    }];
    
    [self.lineView1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.width.mas_equalTo(self.nameTF);
        
        make.height.mas_equalTo(1);
        
        make.top.mas_equalTo(self.realNameTF.mas_bottom).offset(10);
    }];
    
    [self.typeBtnView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self).offset(20);
        
        make.right.mas_equalTo(self).offset(-10);
        
        make.top.mas_equalTo(self.lineView1.mas_bottom).offset(10);
    }];
    
    //下一步
    [self.nextBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.typeBtnView.mas_bottom).offset(35);
        
        make.left.mas_equalTo(self).offset(30);
        
        make.right.mas_equalTo(self).offset(-30);
        
        make.height.mas_equalTo(50);
    }];
}
@end
